package ipad.asia.service.impl;

import ipad.asia.dao.PunishConsumerDao;
import ipad.asia.entity.PunishConsumer;
import ipad.asia.service.PunishConsumerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PunishConsumerServiceImpl implements PunishConsumerService{
    @Autowired
    private PunishConsumerDao punishConsumerDao;

    public List<PunishConsumer> findAll(){
        return punishConsumerDao.findAll();
    }
    public PunishConsumer findById(int id){
        return punishConsumerDao.findById(id);
    }
    public List<PunishConsumer> findByConsumerId(int consumerId){
        return punishConsumerDao.findByConsumerId(consumerId);
    }
    public void waring(int consumerId){
         List<PunishConsumer> punishConsumer=punishConsumerDao.findByConsumerId(consumerId);
        int result= punishConsumer.get(0).getSerious()+1;
        punishConsumer.get(0).setSerious(result);
         punishConsumerDao.save(punishConsumer.get(0));
    }

    @Override
    public void save(PunishConsumer punishConsumer) {
        punishConsumerDao.save(punishConsumer);
    }
}
